window.onload = function(){
	var mod = document.createElement("div");
	var modBg = document.createElement("div");
	var modTitle = document.createElement("div");
	mod.className = "mod";
	modBg.className = "modBg";
	modTitle.className = "modTitle";
	mod.appendChild(modBg);
	mod.appendChild(modTitle);
	document.body.appendChild(mod);
	modBg.onclick = function(){
		mod.style.display = "none";
		mod.removeChild(mod.getElementsByTagName("img")[0]);
		modBg.style.width = "100vw";
		modBg.style.height = "100vh";
	}
}
function showMod(str,img){
	document.getElementsByClassName("modTitle")[0].innerText = str;
	document.getElementsByClassName("mod")[0].style.display = "block";
	var cloneImg = document.createElement("img");
	cloneImg.src = img;
	cloneImg.onclick = null;
	document.getElementsByClassName("mod")[0].appendChild(cloneImg);
	
	var offsetWidth = cloneImg.offsetWidth;
	var offsetHeight = cloneImg.offsetHeight;
	/*如果图片小于屏幕分辨率则执行*/
	if(document.body.scrollWidth>offsetWidth){
		cloneImg.style.left = (document.body.scrollWidth-offsetWidth)/2+"px";
	}else{
		document.getElementsByClassName("modBg")[0].style.width = offsetWidth+"px";
	}
	if(document.body.scrollHeight>offsetHeight){
		cloneImg.style.top = ((document.body.scrollHeight-offsetHeight)/2+30)+"px";
	}else{
		document.getElementsByClassName("modBg")[0].style.height = offsetHeight+"px";
	}
	if (navigator.userAgent.indexOf('Firefox') >= 0){
	    document.getElementsByClassName("modBg")[0].style.height = "100vh";
	}
}